package com.manlost.web.controller;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.manlost.biz.ManlostServiceLocator;
import com.manlost.biz.account.AccountService;
import com.manlost.biz.tag.TagService;
import com.manlost.biz.tag.model.dto.TagInfoDTO;
import com.manlost.web.common.ManLostSession;
import com.manlost.web.common.Properties;
import com.manlost.web.common.WebUser;

@SuppressWarnings({ "unchecked", "rawtypes" })
@Controller
@RequestMapping("/index.htm")
public class IndexController {

    private AccountService accountService = ManlostServiceLocator.getAccountService();
    private TagService          tagService         = ManlostServiceLocator.getTagService();

    @RequestMapping
    public String index(Map model) throws Exception {
        /*model.put("hello", "hello world!");
        model.put("accounts", accountService.listAccount(new ListAccountQuery()));*/
    	WebUser webUser = ManLostSession.getCurrent().getWebUser();
    	List<TagInfoDTO> tagInfos = tagService.listTagInfos();
        model.put("tagInfos", tagInfos);
    	model.put("webUser", webUser);
    	model.put("isSigned", webUser.isSignIn());
    	model.put("imageServer",Properties.PROTOL+Properties.IMAGE_SERVER+":"+Properties.IMAGE_SERVER_PORT);
        return "index";
    }

   /* @RequestMapping(params = "method=get", method = RequestMethod.GET)
    public String getRequest(Map model, String params) {
        model.put("hello", "hello world!");
        model.put("params", params);
        model.put("accounts", accountService.listAccount(new ListAccountQuery()));
        return "index";
    }*/

}
